<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <meta http-equiv="X-UA-Compatible" content="ie=edge">
    <title>Document</title>
    <style>
        div {
            position: absolute;
            left: 0px;
            top: 0px;
            width: 100px;
            height: 100px;
            background: orange;
        }
    </style>
</head>
<body>
    <div></div>


    <script>

        // v = v + at;
        var oDiv = document.getElementsByTagName('div')[0];
        var timer = null;
        oDiv.onclick = function () {
            startMove(this);
        }
        // a为正值，加速度不变的加速运动
        // a为负值，加速度不变的减速运动  减为零后 -> 反向加速
        function startMove (dom) {
            clearInterval(timer);
            var a = -2;
            var iSpeed = 100;
            timer = setInterval(function () {
                iSpeed = iSpeed + a;
                oDiv.style.left = oDiv.offsetLeft + iSpeed + 'px';
            }, 30);
        }




    </script>
</body>
</html>